<?php
  session_start();
  include ("guestbook/database.php");
  include ("guestbook/stringcut.php");
  include ("guestbook/gerdate.php");
  $ip = $_SERVER["REMOTE_ADDR"];
  if (!isset($_POST['submit'])) {
?>
<form action="guestbook.php" method="post">
<table border="0">
<tr><td>Your name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Your email:</td><td><input type="text" name="mail"></td></tr>
<tr><td>Do you have a homepage:</td><td><input type="text" name="www"></td></tr><br>
</table>
<textarea cols="70" rows="10" name="text"></textarea><br>
<input type="submit" name="submit" value="Submit"><br><br>
<?php
  } else {
      if($_SESSION['voted'] == "false" or !isset ($_SESSION['voted'])) {
        $name = $_POST['name'];
        $msg = $_POST['text'];
        $mail = $_POST['mail'];
        $www = $_POST['www'];
        $sql_data = "INSERT INTO guestbook (userip, username, usermsg, usermail, userwww) VALUES ('$ip', '$name', '$msg', '$mail', '$www')";
        mysql_query($sql_data);
        $_SESSION['voted'] = "true";
      }
    }
  $abfrage = "SELECT * FROM guestbook"; 
  $ergebnis = mysql_query($abfrage);
  while($row = mysql_fetch_object($ergebnis))
     {
     $cut = wordwrap($row->usermsg);
     $date = gerdate($row->userdate);
     $rdymsg = htmlspecialchars($cut);
     $userout = $row->username;
     $userwww = $row->userwww;
     $userwww2 = "http://$userwww";
     echo "<A HREF=\"$userwww2\">$userout</A> Date: $date Text:<br />$rdymsg<br /><br />";
     }
  // Created by tweety100, Burning Bird Development, 2010.
?>